import javax.swing.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-01-24
 * Time: 8:32
 */
import java.util.Arrays;

public class TestDemo {

    public static void main(String[] args) {

        int[][] arr = new int[2][];

        arr[0] = new int[2];
        arr[1] = new int[3];

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j] + "  ");
            }
            System.out.println();
        }
    }

    public static void main31(String[] args) {
        int[][] array = {{1, 2}, {4, 5, 6}};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + "  ");
            }
            System.out.println();
        }
    }

    public static void main30(String[] args) {

        int[][] array1 = {{1, 2, 3}, {4, 5, 6}};
        int[][] array2 = new int[][]{{1, 2, 3}, {4, 5, 6}};
        int[][] array3 = new int[2][3];
        System.out.println(Arrays.deepToString(array1));

    }

    public static int[] copOf(int[] arr) {
        int[] ret = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            ret[i] = arr[i];
        }
        return ret;
    }

    public static void main29(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        int[] copy = arr.clone();
        System.out.println(Arrays.toString(copy));
         //int[] copy = new int[arr.length];
        //从arr数组的0位置开始，拷贝到copy数组中，从copy数组的0位置，长度为arr数组的长度
        System.arraycopy(arr,0,copy,0,arr.length);
        System.out.println(Arrays.toString(copy));

        int[] ret =  Arrays.copyOfRange(arr,0,3);// [ )
        System.out.println(Arrays.toString(ret));
       //  int[] ret = Arrays.copyOf(arr,arr.length*2);
       //    int[] ret = copOf(arr);
    }

    public static void func(int[] arr) {
        int left = 0;
        int right = arr.length - 1;
        while (left < right) {
            while (left < right && arr[left] % 2 == 0) {
                left++;
            }
            while (left < right && arr[right] % 2 != 0) {
                right--;
            }
            int tmp = arr[left];
            arr[left] = arr[right];
            arr[right] = tmp;
        }
    }

    public static void main28(String[] args) {
        int[] arr = {1, 2, 3, 6, 8, 4, 7};
        func(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void reverse(int[] array) {
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
            left++;
            right--;
        }
    }

    public static void main27(String[] args) {
        int[] array = {1, 2, 3, 4, 5};
        reverse(array);
        System.out.println(Arrays.toString(array));
    }

    public static void main26(String[] args) {
        int[] arr = new int[10];
        Arrays.fill(arr,2,6,99); //formIndex ~ toIndex  [ 2 , 6 )
        System.out.println(Arrays.toString(arr));
    }

    public static void bubbleSort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            boolean flag = false;
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                    flag = true;
                }
                if (flag == false) {
                    return;
                }
            }
        }
    }

    public static void main25(String[] args) {
        int[] array = {9, 1, 2, 6, 8, 4, 5, 3, 7, 10};
        //bubbleSort(array);
        Arrays.sort(array);
        System.out.println(Arrays.binarySearch(array, 5));
//        System.out.println(Arrays.toString(array));
    }

    public static boolean isUp(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    }

    public static void main24(String[] args) {
        int[] array = {1, 3, 6, 8, 9};
        System.out.println(isUp(array));
    }

    public static String myToString(int[] array) {
        if (array == null) return "null";
        String str = "[";
        for (int i = 0; i < array.length; i++) {
            str = str + array[i];
            if (i != array.length - 1) {
                str += ",";
            }
        }
        str += "]";
        return str;
    }

    public static void main23(String[] args) {
        int[] array = {9, 8, 7, 6, 5, 4, 3, 2, 1};
        System.out.println(myToString(array));
    }

    public static int[] copyOf(int[] array) {
        int[] copy = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            copy[i] = array[i];
        }
        return copy;
    }

    public static void main22(String[] args) {
        int[] array = new int[]{1, 2, 3, 6, 5, 4};
        int[] ret = copyOf(array);
        System.out.println(Arrays.toString(ret));
    }

    public static void bubble_sort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
    }

    public static void main21(String[] args) {
        int[] array = {8, 9, 5, 4, 6, 3, 2, 1, 7, 10};
        bubble_sort(array);
        System.out.println(Arrays.toString(array));
    }

    public static int find(int[] array) {
        int ret = array[0];
        for (int i = 1; i < array.length; i++) {
            ret = ret ^ array[i];
        }
        return ret;
    }

    public static void main20(String[] args) {
        int[] array = {4, 1, 2, 1, 2};
        System.out.println(find(array));
    }

    public static void main19(String[] args) {
        int[] array = new int[100];
        for (int i = 0; i < array.length; i++) {
            array[i] = i + 1;
        }
        System.out.print(Arrays.toString(array));
    }



    public static void printArray(int[] array) {
        for (int i : array) {
            System.out.print(i + "  ");
        }
    }

    public static void main18(String[] args) {
        int[] array = {9, 8, 7, 6, 5, 4, 3, 2, 1};
        printArray(array);
    }

    public static void transform(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = array[i] * 2;
        }
    }

    public static void main17(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        transform(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static int sum(int[] array) {
        int sum = 0;
        for (int i : array) {
            sum += i;
        }
        return sum;
    }

    public static void main16(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        System.out.println(sum(array));
    }

    public static int binarySearch1(int[] array, int key) {
        int left = 0; //左下标
        int right = array.length - 1; //右下标
        while (left <= right) {
            int mind = (left + right) / 2;
            if (key > array[mind]) {
                left = mind + 1;
            } else if (key < array[mind]) {
                right = mind - 1;
            } else if (key == array[mind]) {
                return mind;
            }
        }
        return -(left + 1);
    }

    public static void main15(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        System.out.println(binarySearch1(arr, 7));
    }



    public static int find1(int[] array, int key) {
        for (int i = 0; i < array.length; i++) {
            if (array[i] == key) {
                return i; //返回找到值的下标
            }
        }
        return -1; //如果没找到就返回-1
    }

    public static void main14(String[] args) {
        int[] arr = {14, 15, 16, 3, 8, 2};
        System.out.println(find1(arr, 2));
    }

    public static double avg(int[] array) {
        if (array == null || array.length == 0) return 0;
        int sum = 0;
        for (int i : array) {
            sum += i;
        }
        return (double) sum / array.length;
    }

    public static void main13(String[] args) {
        int[] array = {1, 2, 3, 5, 6};
        System.out.println(avg(array));
    }

    public static int findMax(int[] array) {
        //判断数组如果是没有元素或是null，则返回-1
        if (array == null || array.length == 0) return -1;
        int max = array[0];
        for (int i = 1; i < array.length; i++) {
            if (max < array[i]) {
                max = array[i];
            }
        }
        return max;
    }

    public static void main12(String[] args) {
        int[] array = {12, 1, 6, 99, 84, 3};
        System.out.println(findMax(array));
    }

    public static String myToString2(int[] array) {
        if (array == null) return "null";
        String str = "[ ";
        for (int i = 0; i < array.length; i++) {
            str += array[i];
            if (i != array.length - 1) {
                str += ",";
            }
        }
        str += " ]";
        return str;
    }

    public static void main11(String[] args) {
        int[] array = {1,2,3,4,5};
        System.out.println(myToString2(array));
    }



    public static void myToString1(int[] array){
        System.out.print("[");
        for (int i = 1; i <= array.length-1; i++) {
            System.out.print(i+",");
        }
        System.out.println(array[array.length-1]+"]");
    }
    public static void main10(String[] args) {
        int [] array = {1,2,3,4,5};
        myToString1(array);
        System.out.println();
    }

    public static int[] fun1(int[] arr1) {
        int[] ret = new int[arr1.length];
        for (int i = 0; i < arr1.length; i++) {
            ret[i] = arr1[i] * 2;
        }
        return ret;
    }

    public static void main9(String[] args) {
        int[] arr1 = {1, 2, 3, 4, 5, 6};
        int[] arr = fun1(arr1);
        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.toString(arr1));
    }

    public static void fun3(int[] arr1) {
        for (int i = 0; i < arr1.length; i++) {
            arr1[i] = arr1[i] * 2;
        }
    }

    public static void main8(String[] args) {
        int[] arr1 = {1, 2, 3, 4, 5, 6};
        fun3(arr1);
        System.out.println(Arrays.toString(arr1));
    }

    public static void main7(String[] args) {

        int []arr = null;

        System.out.println(arr[0]);
    }

    public static void func2(int[] arr) {
        arr = new int[]{21, 23, 25, 24, 26};
    }

    public static void main6(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println(Arrays.toString(arr));
        func2(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void func9(int[] arr) {
        arr[0] = 66;
    }

    public static void main5(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println(Arrays.toString(arr));
        func9(arr);
        System.out.println(Arrays.toString(arr));
    }


    public static void main4(String[] args) {
        int[] arr = {1, 2, 3};
        //Arrays.toString 是将参数的数组以字符串的形式输出
        String ret = Arrays.toString(arr);
        System.out.println(ret);
        // System.out.println(Arrays.toString(arr));
    }


    public static void main3(String[] args) {
        int[] arr = {1, 2, 3};
        System.out.println("length = " + arr.length);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        arr[2] = 100;
        System.out.println(arr[2]);
    }

    public static void main2(String[] args) {

        int[] arr = new int[3];

        int[] arr1 = new int[]{1, 2, 3};

        int[] arr2 = {1, 2, 3};
    }


    public static void move(char p1,char p2){
        System.out.print(p1 + " -> " + p2+"   ");
    }
    /**
     * @param n 表示盘子个数
     * @param pos1 盘子所在的起始位置
     * @param pos2 盘子需要中转的位置
     * @param pos3 盘子的结束位置
     * @return 移动的顺序
     */
    public static void hanio (int n,char pos1,char pos2,char pos3){
        if(n==1){
            //如果只有一个盘子：A -> C
            move(pos1,pos3);
        }else{
            // 将n-1 个盘子借助C柱移动到B柱上
            hanio(n-1,pos1,pos3,pos2);
            //将A柱上剩下的一个盘子移动到C柱上
            move(pos1,pos3);
            // 将B柱中的盘子(n-1个盘子)借助A柱移动到C柱上
            hanio(n-1,pos2,pos1,pos3);
        }
    }
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 1; i <=n ; i++) {
            hanio(i,'A','B','C');
            System.out.println();
        }
    }
}
